/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package lambert1.monster1337;

import lambert1.game.Entity;
import lambert1.game.Game;
import lambert1.game.ShotEntity;



/**
 *
 * @author Erik
 */
public class Boss1_LuigiEarthwalker extends Entity {
/** The speed at which the alient moves horizontally */
	private double moveSpeed = 2000.0;
	/** The game in which the entity exists */
	private Game game;

        private double startx = this.x;

	
	/**
	 * Create a new alien entity
	 * 
	 * @param game The game in which this entity is being created
	 * @param ref The sprite which should be displayed for this alien
	 * @param x The intial x location of this alien
	 * @param y The intial y location of this alient
	 */
        
    public Boss1_LuigiEarthwalker(int x, int y) {
		super("sprites/monster.png",x,y, false);
		dx = -moveSpeed;

    }

	/**
	 * Request that this alien moved based on time elapsed
	 * 
	 * @param delta The time that has elapsed since last move
	 */
	public void move(long delta) {
		// if we have reached the left hand side of the screen and
		// are moving left then request a logic update 
		// and vice vesa, if we have reached the right hand side of 
		// the screen and are moving right, request a logic update

		
		// proceed with normal move
		super.move(delta);
                doLogic();
	}
	
	/**
	 * Update the game logic related to aliens
	 */
	public void doLogic() {
		// swap over horizontal movement

            if (x < 0)
                dx = moveSpeed;
            else if (x > Game.GAME_WIDTH)
                dx = -moveSpeed;

            if (y < 0)
                dy = moveSpeed;
            else if (y > Game.GAME_HEIGHT)
                dy = -moveSpeed;

            
            if(this.x <= (startx - 50) || this.x >= (startx + 200)){
		dx = -dx;
                if (dx < 0){
                    dx = dx - 30;
                } else {
                    dx = dx + 30;
                }
                if (dx < -moveSpeed){
                    dx = moveSpeed;
                }
                else if(dx > moveSpeed){
                    dx = -moveSpeed;
                }
                
                // mirrors the image so it seems the monster goes the other way
            }
	}
	
	/**
	 * Notification that this alien has collided with another entity
	 * 
	 * @param other The other entity
	 */
	public void collidedWith(Entity other)
        {
            if (other instanceof lambert1.character.Character)
            {
                Game.getInstance().notifyDeath();
            }
	}
    }

